# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=freedesktop-docs
pkgver=20220526.af8e64a
pkgrel=1
pkgdesc="Specifications from freedesktop.org"
arch=('any')
url="https://standards.freedesktop.org"
license=('GPL')
options=('docs')
makedepends=('git' 'xmlto' 'docbook-utils' 'docbook-xsl' 'docbook-xml' 'docbook-sgml' 'python-gitpython' 'discount')
source=("git+https://gitlab.freedesktop.org/xdg/xdg-specs.git#commit=af8e64a9670c9eb1689a34eb76470cfbc9d1cea3"
	"git+https://gitlab.freedesktop.org/xdg/default-icon-theme.git#commit=b3f1207ccff5ce0ab45ead38031f98fc1abe9731"
	"git+https://gitlab.freedesktop.org/xdg/shared-mime-info.git#commit=fea642e9a88fffc8fb14793a5cbd6c4031d4271b"
	"git+https://gitlab.freedesktop.org/xdg/sound-theme-spec.git#commit=b38cb3916fbb7243a3f4e78284d5613cc9321c8c"
	"git+https://gitlab.freedesktop.org/xdg/startup-notification.git#commit=07237ff25d6171e1b548118442ddba4259a53ba5"
	"git+https://gitlab.freedesktop.org/dbus/dbus.git#commit=b30c2c293d6c599adafca5b82cb7df6351ca2fa1"
	"git+https://gitlab.freedesktop.org/mpris/mpris-spec.git#commit=51e5848f9f763864568db233bffe98e3cb72bf13")
sha256sums=('SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP')

pkgver() {
  cd xdg-specs
  # Commit date + short rev
  echo $(TZ=UTC git show -s --pretty=%cd --date=format-local:%Y%m%d HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd ./xdg-specs
  for d in dbus default-icon-theme shared-mime-info sound-theme-spec startup-notification mpris-spec; do
    rm -rf ./$d || true
    mv "$srcdir"/$d .
  done
  ln -s /usr/bin/mkd2html "$srcdir"/discount-mkd2html
}

build() {
  cd ./xdg-specs/web-export
  # mpris requires python2
  sed -i '/git:mpris/d' specs.idx
  export PATH="$srcdir":$PATH
  ./update.py
  cd ..
  find public -name '*.proc' -delete #find a way to stop these being produced?
}
 
package() {
  cd "$srcdir"/xdg-specs/public
  install -d "$pkgdir"/usr/share/doc/freedesktop.org/
  cp -r --no-preserve=ownership  * "$pkgdir"/usr/share/doc/freedesktop.org/
}
